package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.OrderDetail;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {

     void insert(Orders orders);

     void insertBatch(List<OrderDetail> orderDetailList);

     void update(Orders orders);

    Page<OrdersDTO> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);



    @Select("select * from orders where status = #{status} and order_time < #{time}")
    List<Orders> getTimeoutOrders(Integer status, LocalDateTime time);

    OrdersDTO ordersDTOById(Long id);
    @Select("select * from orders where number=#{orderNumber}")
    Orders getOrdersByOrderNumber(String orderNumber);

    List<OrderDetail> getOrderDetailByOrderId(Long orderId);




    Integer countByMap(Map map);
}
